import { apiSauce } from "@/services/api"

export interface SettingConfig {
  value: string
}

export const getConfig = async () => {
  return apiSauce.get(`/pixel-cat/user/configs?app=pixbird`)
}

export const bindWxUnionId = async (code: string) => {
  console.log("API: 开始绑定微信UnionId请求")
  console.log("API: 请求参数 - code:", code)
  console.log("API: 请求参数 - appId: wxcfe1a3a1e165f408")

  try {
    const response = await apiSauce.get(`/pixel-cat/user/bind_wx_union_id`, {
      code,
      appId: "wxcfe1a3a1e165f408",
    })

    console.log("API: 绑定微信UnionId响应成功")
    console.log("API: 响应状态:", response?.status)
    console.log("API: 响应数据:", response?.data)

    return response
  } catch (error: any) {
    console.log("API: 绑定微信UnionId请求失败")
    console.log("API: 错误信息:", error)
    console.log("API: 错误状态:", error?.response?.status)
    console.log("API: 错误数据:", error?.response?.data)

    throw error
  }
}
